<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        // 给一个数字数组，该数组中有很多数字0，将不为0的数据存入到一个新的数组中
        let arr = [2, 0, 6, 0, 18, 15, 0, 40, 88, 0, 99]
        let sum = []
        for(let i = 0; i < arr.length; i++) {
            if(arr[i] !==0) sum.push(arr[i])
        }
        document.write(`不为0的数据数组${sum}`);
    </script>
</body>
</html>